package com.xlous.example.demo.controller;

import com.alibaba.fastjson.JSON;
import com.xlous.example.demo.model.CtDemo;
import com.xlous.example.demo.service.DemoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 请求控制层类
 */
@RestController
public class DemoController {


     private Logger logger= LoggerFactory.getLogger(DemoController.class);

    @Autowired(required = false)
    private DemoService demoService;

    @RequestMapping("/")
    public String index(){
        return "hello word";
    }


    @RequestMapping("/index")
    public String testService() throws  Exception{
        logger.info("------------------------用户访问index 请求！-----------------------------");
        CtDemo ctDemo =demoService.findListById("A7514B731EB803EDE053CF3D10AC32C1");
        return JSON.toJSONString(ctDemo);
    }

}
